package cn.com.bluemoon.daps.system.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.com.bluemoon.daps.common.domain.BaseModel;
import cn.com.bluemoon.daps.system.dto.IDataWeigth;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.util.Objects;

/**
 * <p>
 * 命名推荐表
 * </p>
 *
 * @author admin
 * @since 2020-08-03
 */
@Data
@Accessors
@ApiModel(value = "DapDataModelNameRecommendation", description = "命名推荐表")
public class DapDataModelNameRecommendation extends BaseModel<DapDataModelNameRecommendation>
        implements IDataWeigth {

    /**
     * 定义默认值
     */
    public static final double DEFAULT_VALUE = 0D;
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "中文名称")
    @Excel(name = "名称")
    @Pattern(regexp = "^[\\u4e00-\\u9fa5]{0,}$", message = "命名推荐中文名只能是中文")
    @Size(max = 32, message = "中文名不能超过32个字符")
    @NotNull(message = "中文名不能为空")
    private String chinName;

    @ApiModelProperty(value = "英文名称")
    @Pattern(regexp = "^[A-Za-z]+$", message = "命名推荐缩写只能是英文")
    @Excel(name = "缩写")
    @Size(max = 16, message = "中文名不能超过16个字符")
    @NotNull(message = "缩写不能为空")
    private String engName;

    @ApiModelProperty(value = "词典类型, 1:限定名, 2:主题词, 3:类别词")
    @NotNull(message = "词典类型不能为空")
    private Integer fieldType;

    @ApiModelProperty(value = "词典类型, 1:限定名, 2:主题词, 3:类别词", hidden = true)
    @TableField(exist = false)
    @Excel(name = "类型")
    private String type;

    @ApiModelProperty(value = "英文全称")
    @Excel(name = "全称")
    @Pattern(regexp = "^[A-Za-z]+$", message = "命名推荐英文名只能是英文")
    @Size(max = 32, message = "英文名不能超过32个字符")
    @NotNull(message = "英文名不能为空")
    private String engFullName;

    @ApiModelProperty(value = "备注、说明")
    @Excel(name = "说明")
    @Size(max = 200, message = "备注不能超过200个字符")
    private String description;

    @ApiModelProperty(value = "数据来源")
    private String dataSource;

    @ApiModelProperty(value = "Excel对应行号", hidden = true)
    @TableField(exist = false)
    private int rowNum;

    @ApiModelProperty("权重数据")
    @TableField(exist = false)
    private double weigthSize = DEFAULT_VALUE;

    @Override
    public double getWeigthSize() {
        return weigthSize;
    }

    @Override
    public void setWeigthSize(double weigthSize) {
        this.weigthSize = weigthSize;
    }


    @Override
    public boolean equals(Object o) {
        //noinspection AliControlFlowStatementWithoutBraces
        if (this == o) {
            return true;
        }
        //noinspection AliControlFlowStatementWithoutBraces
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        //noinspection AliControlFlowStatementWithoutBraces
        if (!super.equals(o)) {
            return false;
        }
        DapDataModelNameRecommendation that = (DapDataModelNameRecommendation) o;
        return Objects.equals(chinName, that.chinName) &&
                Objects.equals(engName, that.engName) &&
                Objects.equals(fieldType, that.fieldType) &&
                Objects.equals(engFullName, that.engFullName);
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), chinName, engName, fieldType, engFullName);
    }
}
